package com.demo.service.impl;

import com.demo.dao.user.UserDao;
import com.demo.entity.user.User;
import com.demo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

//import javax.annotation.Resource;
import java.util.List;

@Service("userService")
public class UserServiceImpl implements UserService {

//    @Autowired
//    @Qualifier(value = "userDao")
    private UserDao userDao;

    @Autowired
    public UserServiceImpl(UserDao userDao) {
        System.out.println("开始注入userDao...");
        this.userDao = userDao;
    }

    @Override
    public List<User> findAll() {
        System.out.println("-----进入服务方法......findAll");
        return this.userDao.findAll();
    }

    @Override
    public User findUser(int id) {
        return null;
    }

    @Override
    public User getUser(int id) {
        return null;
    }

    @Override
    public User findByUserAndPass(String username, String password) {
        System.out.println("-----进入服务方法......findByUserAndPass");
        return this.userDao.findByUserAndPass(username,password);
    }
    @Override
    public int insertUser(User user) {
        System.out.println("-----进入服务方法......insertUser");
        return this.userDao.insert(user);
    }

    @Override
    public int insertSelective(User user) {
        System.out.println("-----进入服务方法......insertSelective");
        return this.userDao.insertSelective(user);
    }

    @Override
    public int updateByPrimaryKey(User user) {
        System.out.println("-----进入服务方法......updateByPrimaryKey");
        return  this.userDao.updateByPrimaryKey(user);
    }

    @Override
    public int updateByPrimaryKeySelective(User user) {
        System.out.println("-----进入服务方法......updateByPrimaryKeySelective");
        return  this.userDao.updateByPrimaryKeySelective(user);
    }

    @Override
    public int deleteByPrimaryKey(Integer id) {
        System.out.println("-----进入服务方法......deleteByPrimaryKey");
        return  this.userDao.deleteByPrimaryKey(id);
    }
}
